package com.prs.crm;

import java.io.File;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Date;


public class MyTest {
	private int a = 0;
	private int k = 0;

	public int aa() {
		int b = 22;
		return a * b;
	}

	public double bb() {
		double d = k * aa() / 22;
		return d;
	}

	public void dd() {
		a = 1000;
		k = 220;
	}
	
	public void random() {		
		int size = 10;
		int count = 0;
		for(;;) {		
			if(count == size) {
				break;
			}
			
			int d = (int)(Math.random()*10);

			if(d < 6) {
				System.out.println(d);
				count ++;
			}		
		}
	}
	
	public static Date convertToDate(String year, String month, String day, String hour, String mi, String sec){
    	try {
    
			if(year.trim().length() > 0 && month.trim().length() > 0 && day.trim().length() > 0){
				return SimpleDateFormat.getDateInstance().parse(year + "-" + month + "-" + day + " " + hour + ":" + mi + ":" + sec);
			}
		} catch (ParseException e) {
			e.printStackTrace();
			return null;
		}
		return null;
	}
	public long getByDays(){
		String ss=setTimeStyleB().format(new Date());
		System.out.println(ss);
		String overTimes=ss+" 59:59:58";
		//结束时间
		Date endtTimes=null;
		Date startTimes=new Date();
		try {
			System.out.println("overTimes:"+overTimes);
			endtTimes=setTimeStyleA().parse(overTimes);
		} catch (ParseException e) {
			e.printStackTrace();
		}
		System.out.println("endtTimes:"+setTimeStyleA().format(endtTimes));
		long ms=(endtTimes.getTime()-startTimes.getTime())/1000;
		return ms;
	}
	public static SimpleDateFormat setTimeStyleA(){
		  SimpleDateFormat ddf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
		  return ddf;
	  }
	  public static SimpleDateFormat setTimeStyleB(){
		  SimpleDateFormat ddf = new SimpleDateFormat("yyyy-MM-dd");
		  return ddf;
	  }
	
	/**
	 * @param args
	 */
	@SuppressWarnings("unused")
	public static void main(String[] args) throws Exception {
		Calendar c = Calendar.getInstance();
		  c.get(Calendar.MONTH);
		  c.roll(Calendar.MONTH, 1);// 切换到下一月
		  c.set(Calendar.DATE, 1);
		  System.out.println(setTimeStyleB().format(c.getTime()));
		File dd=new File("C:\\xx.txt");
		dd.exists();
		
	}
}
